<script>
	import {
		getAccToken
	} from 'userToken.js'
	import {
		encrypt
	} from '@/utils/jsencrypt';
	export default {
		onLaunch() {
			// 初始化登录信息
			this.initLoginUser();
			// 初始化购物车
			this.initCart();
			// 初始化用户信息
			this.getUpdUserInfo();
		},
		onPageNotFound() {
			// 页面不存在时自动重定向到首页
			uni.redirectTo({
				url: '/pages/index'
			});
		},
		onHide() {
			uni.removeStorageSync('hideAd')
		},
		onUnload() {
			uni.removeStorageSync('hideAd')
		},
		onShow() {

		},
		methods: {
			initLoginUser() {
				let loginUser = sessionStorage.getItem('loginUser');
				if (loginUser) {
					loginUser = JSON.parse(loginUser);
					if (loginUser.token) this.$store.commit('login', loginUser);
				}
			},
			initCart() {
				this.$cart.initCart();
			},
			getUpdUserInfo() {
				uni.request({
					url: this.serverUrl + '/user/info',
					method: 'GET',
					header: {
						'authorization': 'Bearer ' + getAccToken(),
						'clientid': '383c41953b35476defd109ac92a82ad6',
						'webuuid': encrypt(this.pageTenantId)
					},
					success: (res) => {
						if (res.data.code == 0 || res.data.code == 200) {
							uni.setStorageSync('userInfo', res.data.data)
						} else {
							uni.removeStorageSync('userInfo')
							uni.removeStorageSync('sellerCartNum')
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import './common/styles/app.scss';

	* {
		outline: none;
	}

	page {
		background-color: rgb(233, 230, 232) !important;
	}

	body {
		background-color: #f5f5f5 !important;
		display: block;
		// max-width: $page-width;
		// min-width: $page-minwidth;
		// margin: 0 auto;
		overflow-x: auto;
		overflow-y: scroll;
		font-size: 14px;
		font-family: "PingFang SC", "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑,Arial", "sans-serif";
		-webkit-user-select: text;
		user-select: text;
	}

	html {
		-webkit-user-select: text !important;
		user-select: text !important;
	}

	a {
		text-decoration: none;

	}

	image {
		-webkit-user-select: none !important;
		user-select: none !important;
	}

	img {
		-webkit-user-select: none !important;
		user-select: none !important;
	}

	button {
		font-size: 14px;
		transition: all .4s;
		border-radius: 0;

		&:active {
			opacity: .8;
		}

		&:after {
			border: none;
		}
	}

	/*去除a标签下划线*/
	a {
		text-decoration: none;
	}

	/*去除未被访问的a标签的下划线*/
	a:link {
		text-decoration: none;
	}

	/*去除已经被访问过的a标签的下划线*/
	a:visited {
		text-decoration: none;
	}

	/*去除鼠标悬停时的a标签的下划线*/
	a:hover {
		text-decoration: none;
	}

	/*去除正在点击的a标签的下划线（鼠标按下，尚未松开）*/
	a:active {
		text-decoration: none;
	}

	/*去除获得焦点的a标签的下划线（被鼠标点击过）*/
	a:focus {
		text-decoration: none;
	}

	/* 图片显示模式 */
	.thumb {
		object-fit: contain;
	}

	/* 省略长文本 */
	.elip {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	/* 省略长文本 展示2行*/
	.elip_2 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box !important;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	/* 省略长文本 展示1行*/
	.elip_1 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box !important;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	
	/*绿色文本*/
	.greText{
		color: #00a67c !important;
	}
</style>